<template>
  <div class="edit-popup">
    <popup
      ref="popupRef"
      title="直播间补发奖励"
      :async="true"
      width="550px"
      @confirm="handleSubmit"
      @close="handleClose"
    >
      <el-form
        ref="formRef"
        :model="formData"
        label-width="120px"
      >
        <el-form-item label="连续签到天数" prop="day" >
          <el-input v-model="formData.day" placeholder="请输入连续签到天数" />
        </el-form-item>
        <el-form-item label="赠送礼品券数量" prop="day" >
          <el-input v-model="formData.day" placeholder="请输入赠送礼品券数量" />
        </el-form-item>
		<el-form-item label="赠送优惠券">
		    <el-radio-group v-model="formData.goods_ids">
				<template v-for="item in gradeList">
					<el-radio :label="item.id">{{item.name}}</el-radio>
				</template>
		    </el-radio-group>
		</el-form-item>
      </el-form>
    </popup>
  </div>
</template>
<script lang="ts" setup>
import type { FormInstance } from "element-plus";
import {
  userCouponList,
} from "@/api/consumer";
import Popup from "@/components/popup/index.vue";
const emit = defineEmits(["success", "close"]);
const formRef = shallowRef<FormInstance>();
const popupRef = shallowRef<InstanceType<typeof Popup>>();

const formData = reactive({
  room_id: "",
});

const gradeList = ref([]);
userCouponList().then((res) => {
	console.log(res)
    gradeList.value = res.list.map((_res: any) => {
        return {id: _res.id, name: _res.name}
    })
});



const open = () => {
  popupRef.value?.open();
};

const handleClose = () => {
  emit("close");
};

defineExpose({
  open
});
//提交
const handleSubmit = async () => {
	formData.rank_id = formData.id
  await formRef.value?.validate();
  await reissue_room(formData)
  popupRef.value?.close();
  emit("success");
};
</script>
